package com.lzc.springboot.controller;

import com.lzc.springboot.domain.Expert;
import com.lzc.springboot.domain.Farmer;
import com.lzc.springboot.service.ExpertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/expert")
public class ExpertController {

  @Autowired
  private ExpertService expertService;

  /**
   * 根据用户查询专家
   * @param expert
   * @return
   */
  @RequestMapping("/findExpertBySearch")
  public Expert[] findExpertBySearch(@RequestBody Expert expert){
    return expertService.findExpertBySearch(expert);
  }

  /**
   * 根据专家ID查询专家
   * @param id
   * @return
   */
  @RequestMapping("/findExpertById")
  public Expert findExpertById(@RequestParam("id") int id){
    return expertService.findExpertById(id);
  }

  /**
   * 查询所有专家
   * @return
   */
  @RequestMapping("/findAllExpert")
  public Expert[] findAllExpert(){
    return expertService.findAllExpert();
  }

  /**
   * 更改专家信息
   * @param expert
   */
  @RequestMapping("/changeExpert")
  public void changeExpert(@RequestBody Expert expert){
    expertService.changeExpert(expert);
  }

  /**
   * 根据专家ID删除专家
   * @param id
   */
  @RequestMapping(value = "/delExpertById",method = RequestMethod.GET)
  public void delExpertById(@RequestParam("id") int id){
    expertService.delExpertById(id);
  }

  /**
   * 查询所有未审核专家
   * @return
   */
  @RequestMapping("/findAllUncheckedExpert")
  public Expert[] findAllUncheckedExpert(){
    return expertService.findAllUncheckedExpert();
  }

  /**
   * 根据查询内容查询专家
   * @param expert
   * @return
   */
  @RequestMapping("/findUncheckedBySearch")
  public Expert[] findUncheckedBySearch(@RequestBody Expert expert){
    return expertService.findUncheckedBySearch(expert);
  }

  /**
   * 根据用户ID查询专家
   * @param uid
   * @return
   */
  @RequestMapping(value = "/findExpertByUid",method = RequestMethod.GET)
  public Expert findExpertByUid(@RequestParam("uid") int uid){
    return expertService.findExpertByUid(uid);
  }

  /**
   * 根据专家输入，修改自身的信息
   * @param expert
   */
  @RequestMapping("/changeExpertByExpert")
  public void changeExpertByExpert(@RequestBody Expert expert){
    expertService.changeExpertByExpert(expert);
  }

  /**
   * 添加专家
   * @param expert
   */
  @RequestMapping("/addExpert")
  public void addExpert(@RequestBody Expert expert){
    expertService.addExpert(expert);
  }
}
